package com.ruoyi.teach.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.teach.domain.SchStudentTuition;
import com.ruoyi.teach.service.ISchStudentTuitionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生缴费Controller
 * 
 * @author ruoyi
 * @date 2021-12-08
 */
@RestController
@RequestMapping("/teach/student_tuition")
public class SchStudentTuitionController extends BaseController
{
    @Autowired
    private ISchStudentTuitionService schStudentTuitionService;

    /**
     * 查询学生缴费列表
     */
    @PreAuthorize("@ss.hasPermi('teach:student_tuition:list')")
    @GetMapping("/list")
    public TableDataInfo list(SchStudentTuition schStudentTuition)
    {
        startPage();
        List<SchStudentTuition> list = schStudentTuitionService.selectSchStudentTuitionList(schStudentTuition);
        return getDataTable(list);
    }

    /**
     * 导出学生缴费列表
     */
    @PreAuthorize("@ss.hasPermi('teach:student_tuition:export')")
    @Log(title = "学生缴费", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SchStudentTuition schStudentTuition)
    {
        List<SchStudentTuition> list = schStudentTuitionService.selectSchStudentTuitionList(schStudentTuition);
        ExcelUtil<SchStudentTuition> util = new ExcelUtil<SchStudentTuition>(SchStudentTuition.class);
        util.exportExcel(response, list, "学生缴费数据");
    }

    /**
     * 获取学生缴费详细信息
     */
    @PreAuthorize("@ss.hasPermi('teach:student_tuition:query')")
    @GetMapping(value = "/{tId}")
    public AjaxResult getInfo(@PathVariable("tId") Long tId)
    {
        return AjaxResult.success(schStudentTuitionService.selectSchStudentTuitionByTId(tId));
    }

    /**
     * 新增学生缴费
     */
    @PreAuthorize("@ss.hasPermi('teach:student_tuition:add')")
    @Log(title = "学生缴费", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SchStudentTuition schStudentTuition)
    {
        return toAjax(schStudentTuitionService.insertSchStudentTuition(schStudentTuition));
    }

    /**
     * 修改学生缴费
     */
    @PreAuthorize("@ss.hasPermi('teach:student_tuition:edit')")
    @Log(title = "学生缴费", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SchStudentTuition schStudentTuition)
    {
        return toAjax(schStudentTuitionService.updateSchStudentTuition(schStudentTuition));
    }

    /**
     * 删除学生缴费
     */
    @PreAuthorize("@ss.hasPermi('teach:student_tuition:remove')")
    @Log(title = "学生缴费", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tIds}")
    public AjaxResult remove(@PathVariable Long[] tIds)
    {
        return toAjax(schStudentTuitionService.deleteSchStudentTuitionByTIds(tIds));
    }
}
